import google.generativeai as genai

### 参考api https://ai.google.dev/api/python/google/generativeai/GenerativeModel
# Replace with your actual API key
api_key = "AIzaSyBJoz7BvdFgWTBwzcu-0xWpJKfEJOR6vPM"

# Configure the API key
genai.configure(api_key=api_key)

# Initialize the GenerativeModel object
model = genai.GenerativeModel('models/gemini-1.5-pro-latest')

for m in genai.list_models():
    if 'generateContent' in m.supported_generation_methods:
        print(m.name)

result = model.generate_content('给我写首关于程序员的诗带点李白写诗的套路', stream=True)
for chunk in result:
    content = chunk.text
    print(len(content))
    print(content)